 function scrollDoor() {}
            scrollDoor.prototype = {
                sd: function(menus, divs, openClass, closeClass) {
                    var _this = this;
                    if (menus.length != divs.length) {
                        alert("菜单层数量和内容层数量不一样!");
                        return false;
                    }
                    for (var i = 0; i < menus.length; i++) {
                        _this.$(menus[i]).value = i;
                        _this.$(menus[i]).onclick = function() {
                            for (var j = 0; j < menus.length; j++) {
                                _this.$(menus[j]).className = closeClass;
                                _this.$(divs[j]).style.display = "none";
                            }
                            _this.$(menus[this.value]).className = openClass;
                            _this.$(divs[this.value]).style.display = "block";
                        }
                    }
                },
                $: function(oid) {
                    if (typeof(oid) == "string") return document.getElementById(oid);
                    return oid;
                }
            }

Cn_User ={
	init : function(busid){
		if(!Jes.userSess(1)) return;//session
		Jes.Door.init('tab',3);
		var type = Jes.request('type') || 1;
		this.query(type,busid);
	}
	,__nameCardId : ''  //全局变量
	//头像图片的处理
	,getPicPath : function(pic){
		if(pic.indexOf('http')!='-1'){
			return pic;
		}else{
			return CONFIG_DATA.headpath + pic;
		}
	}
	//namecard显示
	,namecardshow : function(userid,topicid){
		if(Cn_User.__nameCardId!=null&&Cn_User.__nameCardId!=''){
			var nameCard = Cn_User.__nameCardId.split(',');
			for(var i=0;i<nameCard.length;i++){
				if(Jes(nameCard[i]) == null){
					Cn_User.__nameCardId = Cn_User.__nameCardId.replace(','+nameCard[i],'');
				}else{
					if(nameCard[i]!=null&&nameCard[i]!=''&&Jes(nameCard[i]).style.display=='block'){//之前的还在显示 隐藏掉
					Cn_User.namecardhide(nameCard[i]);
					Cn_User.__nameCardId = Cn_User.__nameCardId.replace(','+nameCard[i],'');
					}
				}
			}
		}
		var nc = document.getElementById(topicid).innerHTML;
		if(nc==null||nc==''){
			Jes.query('namecard_query_sql@idx',{paraObj:"{userid:'"+ userid +"'}",isLoad:false},function(data){
				var html=[];var data=data[0];var single;
				if(data.single==1){
					if(data.sex==1){
						single='<img src="../themes/default/images/ico_boy.gif" title="单身男" />';
					}else{
						single='<img src="../themes/default/images/ico_girl.gif" title="单身女" />';
					}
				}else{
					single='<img src="../themes/default/images/ico_friends.gif" title="不在单身" />';
				}
				html.push('<div class="add_pic_div" id="downdiv02" style="z-index:99">');
					html.push('<div class="details">');
					html.push('<div class="det_pic">');
					html.push('<img src="'+Cn_User.getPicPath(data.pic)+'" />');
					html.push('</div>');
					html.push('<div class="det_right">');
					html.push('<ul>');
					html.push('<li>');
					if(data.remark==null||data.remark==''){
						html.push('<span style = "color:red">'+data.loginid+'(无备注)</span>');
					}else{
						html.push('<span style = "color:red">'+data.loginid+'('+data.remark+')</span>');
					}
					html.push('</li>');
					html.push('<li>'+single+data.area+'  '+data.city+'</li>');
					html.push('<li>关注<span style = "color:red">'+data.follownum+'</span>被关注<span style = "color:red">'+data.fansnum+'</span>活动<span style = "color:red">'+data.reqnum+'</span></li>');
					html.push('</ul>');
					html.push('</div>');
					html.push('<div class="clear"></div>');
					html.push('</div>');
					html.push('<div class="introduction" >'+data.sign+'</div>');
				html.push('</div>');
				Jes.html(topicid,html);
				document.getElementById(topicid).style.display ='block';
			});
		}else{
			document.getElementById(topicid).style.display ='block';
		}
		Cn_User.__nameCardId = Cn_User.__nameCardId +','+ topicid;
	}
	//namecard hide
	,namecardhide : function(topicid){
		document.getElementById(topicid).style.display ='none';
	}
	,query : function(type,busid){
		if(busid!=null&&busid!=''){//活动详情页面过来
			Jes.show('table_yqr');
			Jes('yqruserids').value='';
			Jes('seletedyqr').innerHTML='';
		}
		var page = page || 1,pageSize = pageSize|| 16;
		Jes.page('cnfriend_query_sql',{paraObj:"{type:"+type+",busid:'"+busid+"'}",isLoad:false,page:page,pageSize:pageSize},function(data){
			da = data.pageList;
			var html=[],cls;
			var puserids = parent.Jes('userids').value;
			Jes.each(da,function(i){
				cls = puserids.indexOf(da[i].id)==-1?'choose':'onchoose';
				var username = '';//处理用户名显示过长问题
				if(da[i].remark!=null){
					username = da[i].remark;
				}else{
					username = da[i].loginid;
				}
				if(username.length>4){
					username = username.substr(0,4)+'...';
				}
				//onmouseover="Cn_User.namecardshow(\''+da[i].id+'\',\'np_'+da[i].id+type+'\')" onmouseout="Cn_User.namecardhide(\'np_'+da[i].id+type+'\')"
				html.push('<li><a href="javascript:void(0);" name="user" userid="'+da[i].id+'" loginid="'+da[i].loginid+'" onclick="Cn_User.sel(this);" class="'+cls+'"><img src="'+Cn_User.getPicPath(da[i].pic)+'" /><span class="chopic" id="hidepl"></span></a><p>'
					+ username + '</p><div id="np_'+da[i].id+type+'"></div></li>');
			});
			Jes.html('t',html);
			var html = Jes.Page.html(data,'1');
			Jes.html('user_page',html);
		});
		//this.add();
	}
	//发出邀请
	,yqr : function(){
		var yqrid = userInfo.userid;
		var actid = Jes.request('busid');
		var yqruserids = Jes('yqruserids').value;
		if(yqruserids==null||yqruserids==''){alert('未选中好友');return;}
		Jes.doSaveTObject('CnActuser',{param:{'yqrid':yqrid,'actid':actid,'userids':yqruserids}},function(data){
			alert('发出邀请成功!');
			parent.Jes.close('s');
			Jes.closeWin();
		});
	}
	,sel : function(obj){
		obj.className =(obj.className=='choose')?'onchoose':'choose';
		Cn_User.add();
	}
	,add : function(){
		var puserids = parent.Jes('userids').value;
		var pusernames = '';
		var da = Jes.name('user');
		Jes.each(da,function(i){
			var temp = da[i].loginid;
			if(da[i].className=='onchoose'){
				f=true;
				if(puserids.indexOf(da[i].userid)==-1){
					puserids += (puserids==''?'':'_')+da[i].userid;
				}
				if(pusernames.indexOf(temp)==-1){
					pusernames = pusernames + '<LI onclick="Cn_Act.delUser(this);" ID="'+da[i].userid+'"><P>'+da[i].loginid+'</P><SPAN></SPAN></LI>';
				}
			}else{
				puserids=puserids.replace(da[i].userid+'_','');
				puserids=puserids.replace('_'+da[i].userid,'');
				puserids=puserids.replace(da[i].userid,'');
			}
		});
		parent.Jes('userids').value= puserids;
		parent.Jes.html('friendlist',pusernames);
		Jes('yqruserids').value=puserids;
		Jes('seletedyqr').innerHTML=pusernames;
		parent.Jes.show('noticetype');
	}
	//重置密码
	,rePsd : function(){
		var psd = Jes('password').value;
		var psd2 = Jes('password2').value;
		if(psd==psd2){
			var security = Jes.request('id');
			var userid = Jes.request('userid');
			Jes.doSaveTObject('cn.repsd',{'isSess':0,param:{'security':security,'userid':userid,'password':psd}},function(data){
				if(data=='1'){
					alert('密码重置成功');
					Jes.goUrl('../front/index.html');
					//跳转到首页
				}
			});
		}else{
			alert('两次密码输入不一致');
		}
	}
}
//个人注册
Cn_Reg ={
	init : function(){
		vilidator.init('form1',1);
		Jes('email').onblur = function(){
			vilidator.clearErrorSpan(this);
			Cn_Reg.verifyEmail(this);
		}
		Jes('password').onblur = function(){
			if(this.value.length<6){
				vilidator.clearErrorSpan(this);
				vilidator.printErrorMsg(this,'密码最小六位');
				return;
			}
		}
		var yqr = Jes.request('userid');
		if(yqr!=null&&yqr!=''){
			Jes('yqr').value=yqr;
		}
	}
	,unique : false
	//注册邮箱
	,doSaveUser : function(password,repassword){
		alert(password);
	}
	,verifyEmail : function(el){
		var email = el.value;
		if(email ==''){
			vilidator.printErrorMsg(el,'不允许空。');
			return;
		}
		if(!((vilidator.reg['email']).test(email))) {
			vilidator.printErrorMsg(el,'格式错误。');
			return;
		}
		Jes.doQueryList('cnverify_query_sql@user',{isSess:0,paraObj:'{email:"'+email+'"}',isload:false},function(data){
			if(data[0]){
				var status = data[0].status;
				if(status==1) {
					vilidator.printErrorMsg(el,'此邮件已经被注册。');
					return;
				}else{
					var eService = Cn_Reg.getMailService(email);
					vilidator.printErrorMsg(el,'此邮件已经被注册(待激活)。');//<a href="'+eService+'">未激活</a>
				}
			}else{
				Cn_Reg.unique = true;
			}
		});
	}
	,reg : function(isBus){
		var param = null;
		if(isBus=='-1'){//guang.html
			if($('#email').length==0||!$.formValidator.pageIsValid('1'))return;
			param= Jes.getFormValue('zc_form',1);
		}else{
			param= Jes.getFormValue('form1',1);
		}
		if(param==null) return;
		if(param.password.length<6){alert('密码至少六位数字或字母'); return};
		var f = Jes('agreement').checked;
		if(!f){
			vilidator.printErrorMsg(Jes('agreement'),'没有阅读簇鸟协议怎么能注册呢。');
			return;
		}
		Jes.doQueryList('cnverify_query_sql@user',{isSess:0,paraObj:'{email:"'+Jes('email')+'"}',isLoad:false},function(data){
			if(data[0]){
				vilidator.printErrorMsg(el,'此邮件已经被注册。');
				return;
			}else{
				Jes.doSaveTObject('CnUser',{isSess:0,param:param,isLoad:true},function(data){
					if(isBus=='-1'){
						var email = param.email;
						window.location.href='/cuniao/cuniao/acl/regaccess.html?email='+encodeURI(email);
					}else{
						Jes.html('mod','<h1>查收确认信</h1>'+
			    		'<p>确认信已经发到你的邮箱 '+Jes('email').value+' ，你需要点击邮件中的确认链接来完成注册。</p><br/><br/>'+
			    		'<h2>没有收到确认信怎么办？······</h2><ol><li>1.检查一下上面Email地址是否正确，错了就<a href="../acl/register.html">重新注册</a>一次吧:)</li>'+
			            '<li>2.看看是否在邮箱的垃圾箱里</li><li>3.稍等几分钟，若仍旧没收到确认信，让簇鸟<a href="javascript:Cn_Reg.resend(\''+Jes('email').value+'\');" id="a_resend">重发一封</a></ol>');
						Jes.hide('step');
					}
				});
			}
		});
	}
	//注册成功初始化
	,regaccessInit : function(){
		var email = decodeURI(Jes.request('email'));
		Jes.html('mod','<h1>查收确认信</h1>'+
	    		'<p>确认信已经发到你的邮箱 '+ email +' ，你需要点击邮件中的确认链接来完成注册。</p><br/><br/>'+
	    		'<h2>没有收到确认信怎么办？······</h2><ol><li>1.检查一下上面Email地址是否正确，错了就<a href="../acl/register.html">重新注册</a>一次吧:)</li>'+
	            '<li>2.看看是否在邮箱的垃圾箱里</li><li>3.稍等几分钟，若仍旧没收到确认信，让簇鸟<a href="javascript:Cn_Reg.resend(\''+email+'\');" id="a_resend">重发一封</a></ol>');
	}
	//重发邮件
	,resend : function(email){
		Jes.doSaveTObject('cn.resend',{'isSess':0,param:{'email':email}},function(data){
			alert('邮件已经发出,请再次查收。');
		});
	}
	//邮箱服务器地址
	,getMailService : function(email){
		var es=email.split('@');
		return 'http://mail.'+es[1];
	}
	//校验
	,verify : function(){
		var id = Jes.request('id');
		if(!id) return;
		Jes.doSaveTObject('cn.verify',{'isSess':0,param:{'id':id}},function(data){
			if(data=='ok'){
				alert('您已经注册,请直接登入!');
				Jes.goUrl('/cuniao/');
			}else{
				Jes.goUrl('regmore.html?id='+data);
			}
		});
	}
	,moreInit : function(){
		if(!Jes.userSess(1)) return;//session
		var next = Jes.request('next')|| 1;
		Jes('userids').value='';
		if(next==1){//第一步
			Jes.html('weinfo','欢迎您，您登入邮箱是'+userInfo.email);
			Jes.doSync(function(){//异步函数
				Jes.Select.area();
				Jes('area').value=userInfo.area;
				if(Jes('area').value!='') Jes.Select.city();
				Jes('id').value=userInfo.userid;
			});
			Jes('tagid').value = userInfo.tag;
			Comm.getTag('mytag','tag');
		}else if(next==2){//第二步
			Jes.hide('gotocuniao');
			Jes.html('step','完善信息—><span>上传头像—></span>加好友');
			if(userInfo.pic){
				Jes.html('preview_box','<img id="crop_preview" src="'+Cn_User.getPicPath(userInfo.pic) +'" width="180" width="180">');
				Jes.html('preview_box2','<img id="crop_preview2" src="'+ Cn_User.getPicPath(userInfo.pic) +'" width="50" width="50">');
				Jes.html('upImg','<img id="tx" src="'+ Cn_User.getPicPath(userInfo.pic) +'">');
			}
			Jes.hide('reg_fst'),Jes.show('reg_sed');
		}else if(next==3){//第三步
			Jes.show('gotocuniao');
			var html=[];
			Jes.html('step','完善信息—>上传头像—><span>加好友</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="gotocuniao" href="../front/guang.html" style="color:red;font-size:14px;">-->>进入簇鸟网逛逛 </a>');
			Jes.html('form1','');
			Jes.hide('reg_fst');
			Jes.show('reg_trd');
			Cn_Reg.recommendUser();//推荐用户
			
			/*
			Jes.doQueryList('cnregrecommend_query_sql@user',{isLoad:false},function(data){
				var html=[];
				Jes('alluserids').value='';
				for(var i=0;i<data.length;i++){
					html.push('<li>');
						html.push('<span class="licon"><a href="#" id="'+data[i].id+'" onclick="Cn_Reg.seleted(\''+data[i].id+'\')" class="choose">');
						html.push('<img src= "'+ Cn_User.getPicPath(data[i].pic) +'"/><span class="chopic"></span></a></span>');
						html.push('<div class="details">');
							html.push('<p><span  class="name">'+data[i].loginid+'</span>');
							html.push('<span class="profession">('+data[i].job+')</span></p>');
							html.push('<p class="intro" title="'+data[i].sign+'">'+data[i].sign+'</p>');
						html.push('</div>');
          			html.push('</li>');
          			Jes('alluserids').value = Jes('alluserids').value + data[i].id +',';
				}
				Jes.html("fdpiclist",html);
			});
			*/
		}
		//Cn_ModifyUser.init();
	}
	//选择关注人
	,seleted : function(userid){
		if($('#'+userid).hasClass('onchoose')){
			$('#'+userid).removeClass('onchoose');
			Jes('userids').value=Jes('userids').value.replace(userid+',','');
		}else{
			Jes('userids').value=Jes('userids').value+userid + ',';
			$('#'+userid).addClass('onchoose');
		}
	}
	//加关注
	,doGuanzhu : function(){
		var fuserid = Jes('userids').value;
		if(fuserid.length==0){alert('请先选择关注人');return;}
		Jes.doSaveTObject('cn.guanzhu',{param:{'fuserid':fuserid},isLoad:false},function(data){
			var fuser = fuserid.split(',');
			for(var i=0;i<fuser.length-1;i++){
				var el = Jes(fuser[i]).parentNode.parentNode;
				el.parentNode.removeChild(el);
			}
			alert('关注成功');
			Jes('userids').value='';
			Cn_Reg.recommendUser();
		});
	}
	//全选
	,allSeleted : function(obj){
		var allusers = Jes('alluserids').value.split(',');
		if(obj.checked){
			for(var i=0;i<allusers.length-1;i++){
			if($('#'+allusers[i]).hasClass('onchoose')){
				null;
				}else{
				Jes('userids').value=Jes('userids').value+allusers[i] + ',';
				$('#'+allusers[i]).addClass('onchoose');
				}
			}
		}else{
			for(var i=0;i<allusers.length-1;i++){
			if($('#'+allusers[i]).hasClass('onchoose')){
				$('#'+allusers[i]).removeClass('onchoose');
				Jes('userids').value=Jes('userids').value.replace(allusers[i]+',','');
			}else{
				null;
			}
			}
		}
	}
	,regNext : function(next){
		Jes.goUrl('regmore.html?next='+next);
	}
	,yzemail : function(el){
		$("#email").formValidator({onshow:"绑定后你也可以用邮箱账号登陆",onfocus:"邮箱至少6个字符,最多50个字符",oncorrect:"输入正确"})
		.inputValidator({min:6,max:100,onerror:"你输入的邮箱长度非法,请确认"}).regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"你输入的邮箱格式不正确"});
		Jes.doSync(function(){
			var rsl ='';
			Jes.doQueryList('cnverify_query_sql@user',{isSess:0,paraObj:'{email:"'+el.value+'"}',isload:false},function(data){
				if(typeof(data[0])!='undefined'){
					var status = data[0].status;
					if(status==1) {
						rsl = "此邮件已被注册";
					}
					if(status==0){
						rsl = "此邮件已经被注册(待激活状态)";
					}
				}else{
					Cn_Reg.unique = true;
				}
			});
			$("#email").functionValidator({fun:function(){
				if(rsl==''){
					return true;
				}else{
					return rsl;
				}
			}});
		});
	}
	,exitmail : function(el){
		$("#exitEmail").formValidator({validatorgroup:'2'}).inputValidator({min:6,max:100,onerror:"你输入的邮箱长度非法,请确认"}).
		regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"你输入的邮箱格式不正确"});
		Jes.doSync(function(){
			var rsl ='';
			Jes.doQueryList('cnverify_query_sql@user',{isSess:0,paraObj:'{email:"'+el.value+'"}',isload:false},function(data){
				if(typeof(data[0])=='undefined'){
					rsl = "此邮件账号还未注册";
				}else{
					rsl="";
				}
			});
			$("#exitEmail").functionValidator({fun:function(){
						if(rsl==''){
							return true;
						}else{
							return rsl;
						}
			}});
		});
	}
	,regyzemail : function(el){
		$("#email").formValidator({onshow:"请输入账号",onfocus:"邮箱至少6个字符",oncorrect:"&nbsp;"})
		.inputValidator({min:6,max:100,onerror:"邮箱长度非法,请确认"})
		.regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"邮箱格式不正确"});
		Jes.doSync(function(){
			var rsl ='';
			Jes.doQueryList('cnverify_query_sql@user',{isSess:0,paraObj:'{email:"'+el.value+'"}',isload:false},function(data){
				if(typeof(data[0])!='undefined'){
					var status = data[0].status;
					if(status==1) {
						rsl = "此邮件已被注册";
					}
					if(status==0){
						rsl = "此邮件已被注册";
					}
				}else{
					Cn_Reg.unique = true;
				}
			});
			$("#email").functionValidator({fun:function(){
				if(rsl==''){
					return true;
				}else{
					return rsl;
				}
			}});
		});
	}
	//第三方注册 完善信息页面 初始化
	,regThirdInit : function(){
		if(!Jes.userSess(1)) return;
		$.formValidator.initConfig({formid:"form1",onerror:function(){	}});
		$("#email").formValidator({onshow:"绑定后你也可以用邮箱账号登陆",onfocus:"邮箱至少6个字符,最多50个字符",oncorrect:"输入正确"}).inputValidator({min:6,max:100,onerror:"你输入的邮箱长度非法,请确认"}).regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"你输入的邮箱格式不正确"});
		$("#password").formValidator({onshow:"请输入登陆簇鸟网密码",onfocus:"密码不能为空",oncorrect:"密码合法"}).inputValidator({min:6,onerror:"密码不能小于六位,请确认"});
		$("#password2").formValidator({onshow:"请输入重复密码",onfocus:"两次密码必须一致哦",oncorrect:"密码一致"}).inputValidator({min:6,onerror:"重复密码不能为空,请确认"}).compareValidator({desid:"password",operateor:"=",onerror:"2次密码不一致,请确认"});
		$("#phone").formValidator({onshow:"用来接受活动密码,绝不透露隐私",onfocus:"手机号码格式不正确",oncorrect:"手机号码正确"}).inputValidator({min:11,max:11,onerror:"你输入的手机号码长度有误,请确认"}).regexValidator({regexp:"mobile",datatype:"enum",onerror:"手机号码格式不正确"});
		
		$.formValidator.initConfig({validatorgroup:'2',formid:"form2",onerror:function(){ 	}});
		$("#exitEmail").formValidator({validatorgroup:'2',onshow:"已注册的邮箱账号"}).inputValidator({min:6,max:100,onerror:"你输入的邮箱长度非法,请确认"}).regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"你输入的邮箱格式不正确"});
		//$("#exitPassword").formValidator({validatorgroup:'2',onshow:"请输入登陆密码",onfocus:"密码不能为空",oncorrect:"密码合法"}).inputValidator({min:6,onerror:"密码不能小于六位,请确认"});
		
		Jes('tagid').value = userInfo.tag;
		//Comm.getTag('mytag','tag');
	}
	//职位岗位
	,showJob : function(){
		Jes.doQueryList('job_query_sql@user',{isLoad:false},function(data){
			var html = [];
			for (var i = 0; i < data.length; i++) {
				html.push('<li><a href="javascript:Cn_Reg.selectedJob(\'' + data[i].id + '\',\'' + data[i].jobname + '\')">' + data[i].jobname + '</a></li>');
			}
			Jes.html('option_groups',html);
			Jes.showDiv('#showDiv4');
		});
	}
	/*
	//标签
	,showTag : function(){
		Jes.doQueryList('mytag_query_sql@user',{isLoad:false},function(data){
			var html = [];
			for (var i = 0; i < data.length; i++) {
				html.push('<li><a href="javascript:Cn_Reg.selectedJob(\'' + data[i].id + '\',\'' + data[i].tagname + '\')">' + data[i].tagname + '</a></li>');
			}
			Jes.html('option_groups',html);
			Jes.showDiv('#showDiv4');
		});
	}
	*/
	//选择职业
	,selectedJob : function(jobId,jobName){
		Jes('jobid').value=jobId;
		Jes('jobname').innerHTML=jobName;
		Jes.hide('showDiv4');
	}
	//新增职业
	,addNewJob : function(){
		var newJob = Jes('newJobName').value;
		if(newJob==null||newJob=='')return;
		Jes.doQueryList('unjob_query_sql@user',{paraObj:'{jobname:"'+ newJob +'"}'},function(data){
			if(data.length==0){
			Jes.save('CnJob',{param:{jobname:newJob,num:0,createtime:Jes.getNow()}},function(data){
				Jes('jobid').value=data.id;
				Jes('jobname').innerHTML=newJob;
				Jes.hide('showDiv4');
			});
			}else{
				Jes.alert('该职业已存在');
			}
		});
	}
	//保存信息
	,saveThird : function(){
		if(!$.formValidator.pageIsValid('1'))return;
		var param = DWRExtUtil.getFormValue("form1",1);
		if(param==null||param.email==null||param.password==null)return;
		if(!Cn_Reg.unique)return alert('邮箱已被注册');
		if(param.password.length<6)return alert('密码最少六位');
		if(param.password!=param.password2)return alert('两次输入的密码不一致');
		param.id=userInfo.userid;
		param.bindtype=0;
		param.thirdtype=Jes.request('thirdtype');
		Jes.doSaveTObject('CnUser',{param:param},function(data){
			Jes.hide('mod');
			Jes.html('step','注册成功->绑定信息-><span>添加好友</span>          <a href="/cuniao" style="color:red;font-size:14px;text-align:center;">-->>赶紧进入簇鸟网吧</a>')
			Jes.show('reg_trd');
			Cn_Reg.recommendUser();//推荐用户
		});
	}
	//绑定已注册账号
	,saveExitThird : function(){
		$.formValidator.pageIsValid('2');
		var param = DWRExtUtil.getFormValue("form2",1);
		param.thirdtype=Jes.request('thirdtype');
		Jes.save('cn.binduser',{param:param},function(data){
			if(data=='1'){
				Jes.hide('mod');
				Jes.html('step','注册成功->绑定信息-><span>添加好友</span>      <a href="/cuniao" style="color:red;font-size:14px;text-align:center;">-->>赶紧进入簇鸟网吧</a>')
				Jes.show('reg_trd');
				Cn_Reg.recommendUser();//推荐用户
			}else{
				alert("账号或密码有误");
			}
		});
	}
	//添加好友初始化
	,addFriendInit : function(){
		if(!Jes.userSess(1)) return;
		Cn_Reg.recommendUser();
	}
	//推荐好友算法
	,recommendUser : function(){
		Jes.doSaveTObject('cn.recomuser',{isLoad:false,'isSess':0}, function(data) {
			var html=[];
			Jes('alluserids').value='';
			for(var i=0;i<data.length;i++){
				if(i==14)break;
				html.push('<li>');
					html.push('<span class="licon"><a href="javascript:void(0);" id="'+data[i].userid+'" onclick="Cn_Reg.seleted(\''+data[i].userid+'\')" class="choose">');
					html.push('<img src= "'+ Cn_User.getPicPath(data[i].pic) +'"/><span class="chopic"></span></a></span>');
					html.push('<div class="details">');
							html.push('<p><span  class="name">'+data[i].loginid+'</span>');
							html.push('<span class="profession"></span></p>');
							html.push('<p class="intro" title="'+data[i].sign+'">'+data[i].sign+'</p>');
							html.push('<p class="intro" style="color:red">['+data[i].commend+']</p>');
						html.push('</div>');
          			html.push('</li>');
          		Jes('alluserids').value = Jes('alluserids').value + data[i].userid +',';
			}
			Jes.html("fdpiclist",html);
		});
	}
}

//个人资料设置
Cn_ModifyUser ={
	init : function(){
		if(!Jes.userSess(1)) return;//session
		$('#tab11').removeClass('tabnoseled').addClass('tabseled');
		$('#tab12').removeClass('tabseled').addClass('tabnoseled');
		show(6);
		this.getdealinfo();//订单信息
		this.getMybalance();//个人余额
		if(userInfo.type=='2'){
			Jes.show('tab118');
			this.getVerifyUser();
		}
	}
	//已验证用户
	,getVerifyUser : function(){
		Jes.doQueryList('getlastactid_query_sql@user',{paraObj:'{userid:"'+ userInfo.userid +'"}',isLoad:false},function(data){
			if(data.length!=0){
				Jes('actid').value= data[0].id;
				var html = '<br/><input type="hidden" id="actid"><span style="font-size:16px;">用户活动密码：</span>'
					+'<input style="height:20px;border:1px solid #CCC;" type="text" id="v_psd"/>                   '
					+'<input class="save" name="save" type="button" onclick="Cn_ModifyUser.verifyPsd();" value="验证密码">'
					+'<br/><br/><table class="reg_fst">'
					+'<tr><td>手机号码</td><td>活动密码</td><td>数量</td><td>验证时间</td><td>状态</td></tr>';
				Jes.doQueryList('getactuser_query_sql@user',{paraObj:'{actid:"'+ data[0].id +'"}',isLoad:false},function(data){
					for(var i=0;i<data.length;i++){
						html += '<tr><td>'+data[i].phone.substr(0,3)+'****'+data[i].phone.substr(7,4)+'</td><td>'+data[i].actkey+'</td><td>'
						+ data[i].personnum +'</td><td>'+data[i].verifytime+'</td><td>已验证</td></tr>';
					}
					html += '</table>';
					Jes.html('verify_psd',html);
				})
			}else{
				Jes.hide('tab118');
			}
		})
	}
	,verifyPsd : function(){
		var actkey = Jes('v_psd').value;
		var actid = Jes('actid').value;
		if(actkey==null||actid==null)return;
		Jes.doQueryList('verifypsd_query_sql@user',{paraObj:'{actid:"'+ actid +'",actkey:"'+ actkey +'"}',isLoad:false},function(data){
			if(data.length=='1'){
				alert('验证通过');
				Jes.executeSql({ids:data[0].id,sql:'verifyactkey_update_sql'},function(){
					Cn_ModifyUser.getVerifyUser();
				});
			}else{
				alert('验证失败');
			}
		})
	}
	//余额
	,getMybalance : function(){
		var htmlhead = '',html='',flag={'0':'充值','1':'返利','2':'退款','3':'消费'},type={'0':'支出','1':'收入'};
		Jes.doQueryList('getmybalance_query_sql@user',{isLoad:false},function(data){
			if(data.length>0){
				html = '<table class="reg_fst" width="60%"><tr><td >时间<td/><td>类型<td/><td>收支<td/><td>金额(元)<td/><td>备注<td/></tr>'
			}
			for(var i=0;i<data.length;i++){
				if(data[i].type==2){
					htmlhead = '<br /><br /><p style="font-weight:bold;font-size:14px;">您当前的账户余额是 <span style="font-size:28px;color:red;font-weight:bold;">'
					+data[i].balance+'</span> 元'
					/*
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
					+'充值密码:<input style="border:1px solid #CCC;height:20px;" type="text" id="chongzhi_psd"/>&nbsp;&nbsp;<input type="button" onclick="Cn_ModifyUser.chongzhi()" value="充值"/> 
					*/
					+'</p><br />';
				}else{
					html += '<tr><td>'+data[i].createtime+'<td/><td>'
					+flag[data[i].flag]+'<td/><td>'+type[data[i].type]+'<td/><td>'+ data[i].money + '元<td/><td>'+ Jes.notnull(data[i].remark) +'<td/></tr>';
				}
			}
			if(data.length>0)html += '</table>';
			Jes.html('mybalance',htmlhead+html);
		});	
	}
	//订单
	,getdealinfo : function(){
		var html = '',status='',operate='';
		Jes.doQueryList('getdealinfo_query_sql@user',{isLoad:false},function(data){
			if(data.length>0){
				html = '<table class="reg_fst" width="60%"><tr><td >活动名称<td/><td>数量<td/><td>总价<td/><td>订单状态<td/><td>操作<td/><td>支付时间<td/></tr>'
			}else{
				html = '<h3>目前你还没有订单,赶紧去参加活动吧</h3>';
			}
			for(var i=0;i<data.length;i++){
				var content = '';
				if(data[i].content.length>25){
					content = data[i].content.substr(0,25) + '...';
				}else{
					content = data[i].content;
				}
				if(data[i].status==1){
					status='支付成功';
					operate='<a style="font-size:14px;" href="javascript:Comm.sendActkey(\'簇鸟网 '+data[i].content+'.你的活动密码是：'+data[i].actkey+'。凭此短信就可去参加活动。\',\''+data[i].phone+'\')">发送密码到手机</a>'
				}else if(data[i].status==0){
					status='未支付';
					operate='<a style="font-size:14px;background:#FA0B0D;color:#FFF;" href="../act/actdeal.html?id='+data[i].actid+'">去付款</a>';
				}else{
					status='支付失败';
					operate='<a style="font-size:14px;background:#FA0B0D;color:#FFF;" href="../act/actdeal.html?id='+data[i].actid+'">去付款</a>';
				}
				html += '<tr><td style="font-weight:bold;"><a href="../act/actview.html?id='+data[i].actid+'">'+content+'</a><td/><td>'
					+data[i].personnum+'<td/><td>'+data[i].totalfee+'元<td/><td>'+ status + '<td/><td>'+ operate +'<td/><td>'+ Jes.notnull(data[i].paytime) +'<td/></tr>';
			}
			if(data.length>0)html += '</table>';
			Jes.html('table_dealinfo',html);
		});
	}
	,showInfoInit : function(){
		Jes.syn(userInfo.userid);
		if(!Jes.userSess(1)) return;
		$('#tab11').removeClass('tabseled').addClass('tabnoseled');
		$('#tab12').removeClass('tabnoseled').addClass('tabseled');
		show(1);
		/*
		$.formValidator.initConfig({formid:"form1",onerror:function(){	}});
		$("#loginid").formValidator({onshow:"昵称",onfocus:"不能为空",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"});
		$("#username").formValidator({onshow:"姓名",onfocus:"不能为空",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"});
	//	$("#sign").formValidator({onshow:"请输入重复密码",onfocus:"两次密码必须一致哦",oncorrect:"密码一致"}).inputValidator({min:6,onerror:"重复密码不能为空,请确认"}).compareValidator({desid:"password",operateor:"=",onerror:"2次密码不一致,请确认"});
		$("#phone").formValidator({onshow:"用来接受活动密码,绝不透露隐私",onfocus:"手机号码格式不正确",oncorrect:"手机号码正确"}).inputValidator({min:11,max:11,onerror:"你输入的手机号码长度有误,请确认"}).regexValidator({regexp:"mobile",datatype:"enum",onerror:"手机号码格式不正确"});
		*/
	//	Jes.html('welcome','<h1>您的账号是  '+userInfo.email +'</h1>');
		if(userInfo.pic){
			Jes.html('preview_box','<img id="crop_preview" src="'+Cn_User.getPicPath(userInfo.pic) +'" width="180" width="180">');
			Jes.html('preview_box2','<img id="crop_preview2" src="'+ Cn_User.getPicPath(userInfo.pic) +'" width="50" width="50">');
			Jes.html('upImg','<img id="tx" src="'+ Cn_User.getPicPath(userInfo.pic) +'">');
		}
		Jes.doSync(function(){//同步函数
			Jes.Select.area();
			Jes('area').value = userInfo.area;
			Jes.Select.city();
			Jes('city').value=userInfo.city;
			Jes('id').value=userInfo.userid;
			if(userInfo.job){
				Jes.doQueryList('qurjob_query_sql@user',{paraObj:'{jobid:"'+ userInfo.job +'"}',isLoad:false},function(data){
					Jes.html('jobname',data[0].jobname);
				});
			}else{
				Jes.html('jobname','选择职业,便于找到更多同行朋友');
			}
		});
		Jes.setFormValue('form1',userInfo);
		//个人标签
		Jes('tagid').value = userInfo.tag;
		Comm.getTag('mytag','tag');
		this.synInit();
	}
	//个人信息
	,showinfo : function(){
		var html ='	<li id="tab111" class="tabseled"><a href="javascript:void(0);" onclick="show(1);">基本信息</a></li>'
				+'<li id="tab112" class="tabnoseled"><a href="javascript:void(0);" onclick="show(2);">个人头像</a></li>'
				+'<li id="tab113" class="tabnoseled"><a href="javascript:void(0);" onclick="show(3);">个人标签</a></li>'
				+'<li id="tab114" class="tabnoseled"><a href="javascript:void(0);" onclick="show(4);">第三方账号绑定</a></li>'
				+'<li id="tab115" class="tabnoseled"><a href="javascript:void(0);" onclick="show(5);">密码设置</a></li>';
		Jes.html('tabbar12',html);
		this.showInfoInit();
	}
	//个人账户
	,showaccount : function(){
		var html ='<li id="tab116" class="tabseled"><a href="javascript:void(0);" onclick="show(6);">我的订单</a></li>'
				+'<li id="tab117" class="tabnoseled"><a href="javascript:void(0);" onclick="show(7);">我的余额</a></li>'
				+'<li id="tab118" class="tabnoseled" style="display:none"><a href="javascript:void(0);" onclick="show(8);">活动密码审核</a></li>';
		Jes.html('tabbar12',html);
		this.init();
	}
	//账号绑定初始化 10.15
	,synInit : function(){
		Jes.doQueryList('syninfo_query_sql@user',null,function(data){
			var html = [];//innerHTML
			for(var i=0;i<data.length;i++){
				if(data[i].cfrom=='SINA'&&data[i].flag=='1'){
					Jes('synsina').innerHTML='取消绑定';
					Jes('synsina').style.color='';
					Jes('synsina').href='javascript:Cn_ModifyUser.bindCancel(\'SINA\');';
				}
				if(data[i].cfrom=='QQ'&&data[i].flag=='1'){
					Jes('synqq').innerHTML='取消绑定';
					Jes('synqq').style.color='';
					Jes('synqq').href='javascript:Cn_ModifyUser.bindCancel(\'QQ\');';
				}
			}
		}); 
	}
	//用户绑定
	,bind : function(type){
		alert('待开发');
	}
	//用户取消绑定
	,bindCancel : function(type){
		Jes.executeSql({ids:userInfo.userid,type:type,sql:'bindcancel_update_hql'},function(){
			alert('成功取消绑定');
			Jes('syn'+type.toLowerCase()).innerHTML='绑定';
			Jes('syn'+type.toLowerCase()).style.color='red';
			Jes('syn'+type.toLowerCase()).href='javascript:Cn_ModifyUser.bind(\''+type+'\');';
		});
	}
	//保存设置
	,save : function(type){
		var param= Jes.getFormValue('form1',1);
		if(param==null) return;
		param.job = Jes('jobid').value;
		var sex = param.sex.split('_');
		Jes.each(sex,function(i){
			if(this!='null') param.sex = this;
		});
		var single = param.single.split('_');
		Jes.each(single,function(i){
			if(this!='null') param.single = this;
		});
		Jes.doSaveTObject('CnUser',{param:param},function(data){
			if(type!=1){//修改
				Cn_Reg.regNext(2);
			}else{
				Jes.alert('保存成功');
			}
		});
	}
	,modifyUserPic : function(){
		var param= Jes.getFormValue('form2',0);
		if(param==null) return;
		Jes.doSaveTObject('cn.modifyuserpic',{param:param},function(data){
			alert('修改成功');
			Jes.Upload.again();
			Jes.html('upImg','<img id="tx" src="'+Cn_User.getPicPath(data.pic)+'">');//原始尺码图片
			Jes.html('preview_box','<img id="crop_preview" src="'+Cn_User.getPicPath(data.pic) +'" width="180" width="180">');//大图
			Jes.html('preview_box2','<img width="50" width="50" id="crop_preview2" src="'+Cn_User.getPicPath(data.pic) +'">');//小图
		});
	}
	,modifyPsd : function(){
		var param= Jes.getFormValue('form4',1);
		if(param==null) return;
		Jes.doSaveTObject('cn.modifypsd',{param:param},function(data){
			alert('修改成功');
			Jes('oldpsd').value='';
			Jes('newpsd').value='';
			Jes('cfmpsd').value='';
		});
	}
	//忘记密码->找回密码
	,findPsd : function(){
		var param= Jes.getFormValue('form1',1);
		if(param==null) return;
		Jes.doSaveTObject('cn.findpsw',{'isSess':0,param:param,isLoad:false},function(data){
			//未做 参考注册界面
			if(data=='1'){
				//var eService = Cn_Reg.getmailservice(email);
				Jes.html('content','<h1>重设密码</h1><p class="item extra-tips">请到<span id="email" style="color:#F00" >'+param.email+'</span> 查阅来自簇鸟网的邮件，从邮件中的重设密码。</p>');
			}else if(data=='3'){
				alert('该邮箱还未注册');
			}else{
				alert('邮箱账号重置密码出错,请联系客服');
			}
		});
	}
	//判断账号唯一性
	,checkLoginid : function(obj){
		var loginid = obj.value;
		if(loginid=='') return;
		Jes.doQueryList('cnverloginid_query_sql@user',{paraObj:'{loginid:"'+ loginid +'"}'},function(data){
			if(data[0]){
				alert('此昵称太受欢迎，已有人抢注了');
				obj.value='';
			}
		});
	}
	//判断是否修改了手机号码
	,checkPhone : function(obj){
		if(obj.value.length!=11){
			vilidator.printErrorMsg(obj,'手机位数不对');
			return;
		}
	}
	//发送验证码
	,sendYzm : function(){
		
		
	}
}


Jes.Upload = {
	again : function(){
		Jes('upload').disabled=false;
		$("avatar_pic").outerHTML  = $("avatar_pic").outerHTML;//avatar_pic <- attachfile
		//JESUtil.hide("procBar");
	}
	,upload : function(){
		if($("avatar_pic").value == ""){alert("上传头像不能为空！");return;}
		/*
		Jes.show("procBar");
    	$("procBarTxt").innerHTML = "上传进度: 0%";
    	$("procBarBoxCont").style.width = "0px";
    	*/
    	//Jes.disBtns();
    	Jes('upload').disabled=true;
    	//window.setTimeout("Jes.Upload._reProcess()", 1000);
    	//return true;
		Jes('form2').submit();
	}
	,_reProcess : function(){
		Jes.doAction("getBussInfo","UPPROC_INFO",function(_d){
			if(_d.isProcess){
				$("procBarTxt").innerHTML = _d.procInfo;
				$("procBarBoxCont").style.width = parseInt(_d.procPer * 2.16) + "px";
				window.setTimeout("Jes.Upload._reProcess()", 100);
			}else{
				$("procBarBoxCont").style.width = "216px";
				$("procBarTxt").innerHTML = "<p><font color='red'>"+_d.procInfo+"</font></p><p><input type='button' value='继续上传' onclick='JesUpload.uploadAgain();'/>&nbsp;&nbsp;<input type='button' value='关 闭' onclick=\"JESUtil.closeWin();\"/></p>";
				JESUtil.disBtns(false);
			}
		});
	}
	,callBack : function(data){
		var el = Jes('upImg');
		//var taEl=Jes('upTable'),tr,td;
		try{
			var src = data.httppath+data.name;
			Jes('txsrc').value=data.name;
			Jes.html('upImg','<img id="tx" src="'+src+'">');//原始尺码图片
			Jes.html('preview_box','<img id="crop_preview" src="'+src +'">');//大图
			Jes.html('preview_box2','<img id="crop_preview2" src="'+src +'">');//小图
			Jes.JcropInit('tx',{
				boxWidth: 290
				,boxHeight: 290
				,aspectRatio: 1
				,setSelect: [0, 0, 180, 180]
				,onChange:selPic
				,onSelect:selPic
			});
	    }catch(e){
			alert("获得附件信息失败，请联系管理员。");
		}
	}
}

function selPic(coords){
	if(parseInt(coords.w) > 0){
		Jes.setFormValue('form2',coords);
		//计算预览区域图片缩放的比例，通过计算显示区域的宽度(与高度)与剪裁的宽度(与高度)之比得到
		var rx = 180 / coords.w,ry = 180 / coords.h,rx2 = 50 / coords.w,ry2 = 50 / coords.h;
		//通过比例值控制图片的样式与显示
		var w = Jes.width('tx'),h = Jes.height('tx');
		Jes.setStyle('crop_preview',{
			width:Math.round(rx * w) + 'px',
			height:Math.round(rx * h) + 'px',
			marginLeft:"-" + Math.round(rx * coords.x) + "px",
			marginTop:"-" + Math.round(ry * coords.y) + "px"
		});
		Jes.setStyle('crop_preview2',{
			width:Math.round(rx2 * w) + 'px',
			height:Math.round(rx2 * h) + 'px',
			marginLeft:"-" + Math.round(rx2 * coords.x) + "px",
			marginTop:"-" + Math.round(ry2 * coords.y) + "px"
		});
	}
}
